#include<iostream>
using namespace std;
int a,b,n;
int cnt1,cnt2;
int main()
{
	cin>>a>>b>>n;
	while(n--)
	{
		if(a<0)
		{
			cout<<'A'<<endl;
			cout<<cnt2<<endl;
			return 0;
		}
		if(b<0)
		{
			cout<<'B'<<endl;
			cout<<cnt1<<endl;
			return 0;
		}
		int a1,a2,b1,b2;
		cin>>a1>>a2>>b1>>b2;
		int sum=a1+b1;
		if(a2==sum&&b2==sum)
		continue;
		else if(a2!=sum&&b2!=sum)
		continue;
		else if(a2==sum)
		cnt1++,a--;
		else if(b2==sum)
		cnt2++,b--;
	}
    if(a<0)
	{
		cout<<'A'<<endl;
		cout<<cnt2<<endl;
		return 0;
	}
	if(b<0)
	{
		cout<<'B'<<endl;
		cout<<cnt1<<endl;
		return 0;
	}
	return 0;
}
